var sceneName = __3DScene;
if (!sceneName) {
	sceneName = "SceneURP";
	console.warn("__3DScene 未定义 使用默认环境：" + sceneName);
}

window.__hFromUinty = (t) => {};

var abpath = (window.__abpath || "lib/uwebgl/") + "StreamingAssets";
var buildUrl = "lib/uwebgl/Build";
var loaderUrl = `${buildUrl}/${sceneName}.loader.js`;
//var s1GB = 1 * 1024 * 1024 * 1024 * 1; // 1073741824;B-KB-MB-GB

var config = {
	//TOTAL_MEMORY: s1GB / 2,
	dataUrl: `${buildUrl}/${sceneName}.data`,
	frameworkUrl: `${buildUrl}/${sceneName}.framework.js`,
	codeUrl: `${buildUrl}/${sceneName}.wasm`,
	streamingAssetsUrl: abpath,
	companyName: "DefaultCompany",
	productName: "Base-URP",
	productVersion: "0.1",
	showBanner: hShowBanner,
};

if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
	// Avoid draining fillrate performance on mobile devices,
	// and default/override low DPI mode on mobile browsers.
	config.devicePixelRatio = 1;
	console.warn("移动设备不支持WebGL构建");
}
window.ujsDone = false;
var script = document.createElement("script");
script.src = loaderUrl;
script.setAttribute("type", "text/javascript");

script.onload = () => {
	ujsDone = true;
};
document.body.appendChild(script);


function hShowBanner(msg, type) {
	console.log("banner:" + msg, type);
}

/**
 * @param {Object} domCanvas    canvas dom
 * @param {Object} cbkLoading  加载进度回调
 * @param {Object} cbkDone		加载完成回调
 */
function UnityInstance(domCanvas, cbkLoading, cbkDone) {
	createUnityInstance(domCanvas, config, (progress) => {
		//progressBarFull.style.width = 100 * progress + "%";
		cbkLoading(progress);
	}).then((unityInstance) => {
		//加载完成
		cbkDone(unityInstance);
	}).catch((message) => {
		console.log(message);
		alert(message);
	});
}
